const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const commonConfigure = require('./webpack.common');
const { DIST_PATH, PUBLIC_PATH, EXCLUDE_PATH } = require('./utils/variable');

const configure = {
    mode: 'development',
    cache: {
        type: 'memory'
    },
    stats: 'errors-only',
    watchOptions: {
        aggregateTimeout: 500,
        poll: 1000,
        ignored: EXCLUDE_PATH,
    },
    devServer: {
        static: {
            directory: PUBLIC_PATH
        },
        // host: '0.0.0.0',
        compress: true,
        // 指定监听请求的端口号：
        port: 8009,
        // 启用 webpack 的 热模块替换 特性：
        hot: true,
        // 告诉 dev-server 在服务器已经启动后打开浏览器。设置其为 true 以打开你的默认浏览器
        //open: true,
        client: {
            // 在浏览器中以百分比显示编译进度。
            progress: true,
        },
        // allowedHosts: [
        //     'host.com',
        //     'subdomain.host.com',
        //     'subdomain2.host.com',
        //     'host2.com',
        // ],
    }
};

// 合并
const mergeConfigure = webpackMerge.merge(commonConfigure, configure);
// 导出
module.exports = mergeConfigure;